﻿using System;
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms.Design;
using System.Xml.Serialization;
using Landpy.CruiseControlNet.Infrastructure.Control;

namespace Landpy.CruiseControlNet.FacadeInterface.ConfigurationModule
{
    public class Exec : Task
    {
        [Category("Basic")]
        [Description(@"Any command line arguments to pass in. (E.g: -projectName=C:\CIServer\SandCastleProject\Foundation.shfbproj -websiteFolder=C:\CIServer\SandCastleProject\Help)")]
        [XmlElement("buildArgs")]
        public string BuildArgs { get; set; }

        [Category("Basic")]
        [Description(@"Number of seconds to wait before assuming that the process has hung and should be killed. If the build process takes longer than this period, it will be killed. Specify this value as zero to disable process timeouts.")]
        [XmlElement("buildTimeoutSeconds")]
        public int BuildTimeoutSeconds { get; set; }

        [Category("Basic")]
        [Description("The path of the program to run. If this is relative, then must be relative to either (a) the base directory," +
                     " (b) the CCNet Server application, or (c) if the path doesn't contain any directory details then can be available" +
                     " in the system or application's 'path' environment variable.")]
        [Editor(typeof(FileNameEditor), typeof(UITypeEditor))]
        [XmlElement("executable")]
        public string Executable { get; set; }

        [Category("Basic")]
        [Description("The directory to run the process in. If relative, is a subdirectory of the Project Working Directory.")]
        [Editor(typeof(FileLocationEditor), typeof(UITypeEditor))]
        [XmlElement("baseDirectory")]
        public string BaseDirectory { get; set; }

        [Category("Basic")]
        [Description(@"Description used for the visualisation of the buildstage, if left empty the process name will be shown.")]
        [XmlElement("description")]
        public string Description { get; set; }

        [Category("Basic")]
        [Description("The priority class of the spawned process.")]
        [XmlElement("priority")]
        public PriorityType Priority { get; set; }

        public Exec()
            : base(TaskType.Exec)
        {
            this.BuildArgs = String.Empty;
            this.Executable = String.Empty;
            this.BaseDirectory = String.Empty;
            this.Description = String.Empty;
            this.Priority = PriorityType.Normal;
            this.BuildTimeoutSeconds = 600;
        }
    }
}